# ============================================
# Heterogeneity Test: Debt Level (Nickel & Vansteenkiste hypothesis)
# Split BBR sample at the MEDIAN of country-average debt
# High-debt: 11 treated + 30 control | Low-debt: 12 treated + 28 control
# Theory: twin deficits stronger in LOW-debt; weaker/Ricardian in HIGH-debt
# ============================================
# --- Packages ---
library(readxl)
library(dplyr)
library(fect)
library(ggplot2)
# --- Winsorize helper (same as main script) ---
winsorize <- function(x, p = c(0.01, 0.99)) {
q <- quantile(x, probs = p, na.rm = TRUE)
x[x < q[1]] <- q[1]
x[x > q[2]] <- q[2]
return(x)
}
# --- Load data & build BBR sample (same as main script) ---
df <- read_excel("GSCM_Rebuilt_Dataset.xlsx", sheet = "Data")
